Tables [dbo].[OpportunityHistory]
Properties
PropertyValue
Created10:31:29 AM Tuesday, March 02, 2010
Last Modified1:20:15 PM Thursday, February 23, 2012
Columns
NameData TypeMax Length (Bytes)Allow NullsDefault
Cluster Primary Key PK_OpportunityHistory: OpportunityHistoryKeyOpportunityHistoryKeyuniqueidentifier16
No
(newid())
Foreign Keys FK_OpportunityHistory_OpportunityMain: [dbo].[OpportunityMain].OpportunityKeyIndexes IX_OpportunityHistory_OpportunityKey: OpportunityKeyOpportunityKeyuniqueidentifier16
No
PropertyNamenvarchar(50)100
No
OriginalValuenvarchar(250)500
Yes
CurrentValuenvarchar(250)500
Yes
Notesnvarchar(250)500
Yes
UpdatedOndatetime8
No
Foreign Keys FK_OpportunityHistory_UserMain_UpdatedBy: [dbo].[UserMain].UpdatedByUserKeyIndexes IX_OpportunityHistory_UpdatedByUserKey: UpdatedByUserKeyUpdatedByUserKeyuniqueidentifier16
No
Foreign Keys FK_OpportunityHistory_UserMain_CreatedBy: [dbo].[UserMain].CreatedByUserKeyIndexes IX_OpportunityHistory_CreatedByUserKey: CreatedByUserKeyCreatedByUserKeyuniqueidentifier16
No
CreatedOndatetime8
No
MarkedForDeleteOndatetime8
Yes
Indexes Indexes
NameColumnsUnique
Cluster Primary Key PK_OpportunityHistory: OpportunityHistoryKeyPK_OpportunityHistoryOpportunityHistoryKey
Yes
IX_OpportunityHistory_CreatedByUserKeyCreatedByUserKey
IX_OpportunityHistory_OpportunityKeyOpportunityKey
IX_OpportunityHistory_UpdatedByUserKeyUpdatedByUserKey
Foreign Keys Foreign Keys
NameColumns
FK_OpportunityHistory_OpportunityMainOpportunityKey->[dbo].[OpportunityMain].[OpportunityKey]
FK_OpportunityHistory_UserMain_CreatedByCreatedByUserKey->[dbo].[UserMain].[UserKey]
FK_OpportunityHistory_UserMain_UpdatedByUpdatedByUserKey->[dbo].[UserMain].[UserKey]
SQL Script
CREATE TABLE [dbo].[OpportunityHistory]
(
[OpportunityHistoryKey] [uniqueidentifier] NOT NULL CONSTRAINT [DF_OpportunityHistory_OpportunityHistoryKey] DEFAULT (newid()),
[OpportunityKey] [uniqueidentifier] NOT NULL,
[PropertyName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[OriginalValue] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CurrentValue] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Notes] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[UpdatedOn] [datetime] NOT NULL,
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[OpportunityHistory] ADD CONSTRAINT [PK_OpportunityHistory] PRIMARY KEY CLUSTERED ([OpportunityHistoryKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OpportunityHistory_CreatedByUserKey] ON [dbo].[OpportunityHistory] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OpportunityHistory_OpportunityKey] ON [dbo].[OpportunityHistory] ([OpportunityKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_OpportunityHistory_UpdatedByUserKey] ON [dbo].[OpportunityHistory] ([UpdatedByUserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OpportunityHistory] ADD CONSTRAINT [FK_OpportunityHistory_OpportunityMain] FOREIGN KEY ([OpportunityKey]) REFERENCES [dbo].[OpportunityMain] ([OpportunityKey])
GO
ALTER TABLE [dbo].[OpportunityHistory] ADD CONSTRAINT [FK_OpportunityHistory_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[OpportunityHistory] ADD CONSTRAINT [FK_OpportunityHistory_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
Uses